package day16.zhiyou100;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
public class Demo04 {
    //
    public static void m1() throws IOException {
        File file = new File("D:\\file\\book\\cc\\cc.txt");
        InputStream is = new FileInputStream(file);
        // 读数据 read()
        int read = is.read();// 一个字节值
        System.out.println((char) read);
        System.out.println("------");
        byte[] b = new byte[52];
        // 读取数据 int read(byte[] b)
        int read2 = is.read(b);
        // 字节转换成字符
        String str = new String(b);
        System.out.println(str);
        System.out.println(read2);// 字符 ---> 空格
    }
    // 读完一个文件中的所有数据 read() 返回值是否为-1
    public static void m3() throws IOException {
        File file = new File("D:\\file\\book\\cc\\cc.txt");
        InputStream is = new FileInputStream(file);
        int b = 0;
        List<Integer> list = new ArrayList<>();
        while (( b = is.read()) != -1) {
            System.out.print((char) b + ",");
            list.add(b);
        }

    }
    public static void main(String[] args) throws IOException{
        m3();
    }
}
